<style lang="less" scoped src="./info.less"></style>
<script src="./info.js"></script>

<template>
    <div>
        <Row>
            <Col span="22">
            <span @click="showAdd"><Button type="primary" icon="android-add">新增</Button></span>
            </Col>
            <Col span="2">
            <span @click="deleteByIds"><Button type="error" icon="ios-remove">批量删除</Button></span>
            </Col>
        </Row>
        <div class="main-table">
            <Table border :columns="columns" :data="data" @on-selection-change="getSelect"></Table>
        </div>
        <div class="pagination">
            <Page :total="total" size="small" :page-size="pageSize" :current.sync="pageIndex" @on-change="loadList" show-total show-elevator></Page>
        </div>
        <Modal
                v-model="viewModal"
                title="级别信息"
                @on-ok="viewModal = false"
                @on-cancel="viewModal = false"
                width="40%">
            <Form :model="formData" :label-width="70">
                <FormItem label="标题" prop="title">
                    <Input v-model="formData.title" clearable></Input>
                </FormItem>
                <FormItem label="内容" prop="content">
                    <Input v-model="formData.content" type="textarea" :rows="10"/>
                </FormItem>
            </Form>
        </Modal>
        <Modal v-model="editModal"
               :title="(formData.id ? '修改' : '新增') + '信息'"
               width="40%"
               @on-cancel="editModal = false">
            <Form ref="editForm"
                  :model="formData"
                  :label-width="70"
                  :rules="ruleInline">
                <FormItem label="标题" prop="title">
                    <Input v-model="formData.title" clearable></Input>
                </FormItem>
                <FormItem label="内容" prop="content">
                    <Input v-model="formData.content" type="textarea" :rows="10"/>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="primary" @click="save('editForm')">保存</Button>
                <Button type="ghost" style="margin-left: 8px" @click="editModal = false">取消</Button>
            </div>
        </Modal>
        <Modal v-model="pushModal"
               title="选择推送学员"
               width="70%"
               :mask-closable="false"
               @on-cancel="pushModal = false">
            <member-list ref="memberList" ids="" @onSelect="memberSelect"></member-list>
            <div slot="footer">
                <Button type="primary" @click="pushSave">确认</Button>
                <Button type="ghost" style="margin-left: 8px" @click="pushModal = false">取消</Button>
            </div>
        </Modal>
    </div>
</template>